class TopsController < ApplicationController
  # GET /tops
  # GET /tops.xml
  def index
    @tops = Top.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @tops }
    end
  end

  # GET /tops/1
  # GET /tops/1.xml
  def show
    @top = Top.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @top }
    end
  end

  # GET /tops/new
  # GET /tops/new.xml
  def new
    @top = Top.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @top }
    end
  end

  # GET /tops/1/edit
  def edit
    @top = Top.find(params[:id])
  end

  # POST /tops
  # POST /tops.xml
  def create
    @top = Top.new(params[:top])

    respond_to do |format|
      if @top.save
        flash[:notice] = 'Top was successfully created.'
        format.html { redirect_to(@top) }
        format.xml  { render :xml => @top, :status => :created, :location => @top }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @top.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /tops/1
  # PUT /tops/1.xml
  def update
    @top = Top.find(params[:id])

    respond_to do |format|
      if @top.update_attributes(params[:top])
        flash[:notice] = 'Top was successfully updated.'
        format.html { redirect_to(@top) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @top.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /tops/1
  # DELETE /tops/1.xml
  def destroy
    @top = Top.find(params[:id])
    @top.destroy

    respond_to do |format|
      format.html { redirect_to(tops_url) }
      format.xml  { head :ok }
    end
  end
end
